


import { create } from "zustand";

interface PriceStore {
  price: number;
  state:number;
  incrementPrice: () => void;
  decrementPrice: () => void;
  resetPrice: () => void;
  get: () => number;
}

const usePriceStore = create<PriceStore>((set,get) => ({
  price: 0,
  state:123,
  incrementPrice: () => set((state) => ({ price: state.price + 1 })), // 默认合并第一层对象，不必...结构合并
  decrementPrice: () => set((state) => ({ price: state.price - 1 })),
  resetPrice: () => set(() => ({ price: 0 })),
  get: () => get().price,
}));

export default usePriceStore;